/** Permission */
package domain.permissions;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * Enumeration for all of the Permissions used by the system.
 * @author jessienewman
 * @version $Revision: 1.0 $
 */
public enum Permission {
	
	/**
	 * Field DOCTORS_ORDER.
	 */
	DOCTORS_ORDER("doctorsOrders"),
	/**
	 * Field EDIT_PATIENT.
	 */
	EDIT_PATIENT("editPatient"),
	/**
	 * Field INVOICE.
	 */
	INVOICE("invoice"),
	/**
	 * Field ADMIN.
	 */
	ADMIN("administrator"),
	
	PATIENT("patient"),
	
	DOCTOR("doctor");
	
	/**
	 * Field permission.
	 */
	private final String permissionString;
	
	/**
	 * Field lookup.
	 */
	private static final Map<String, Permission> LOOKUP = 
		new HashMap<String, Permission>();

	static {
	    for(Permission permission : EnumSet.allOf(Permission.class))
	         LOOKUP.put(permission.toString(), permission);
	}
	
	/**
	 * Constructor for Permission.
	 * @param permission String
	 */
	private Permission(final String permission) {
		this.permissionString = permission;
	}
	
	/**
	 * Method toString.
	 * @return String
	 */
	public String toString() {
		return permissionString;
	}
	
	/**
	 * Method getPermission.
	 * @param permission String
	 * @return Permission
	 */
	public static Permission getPermission(final String permission) {
		return LOOKUP.get(permission);
	}

}
